<template>
  <div class="detail-page">
    <van-nav-bar
      left-text="返回"
      @click-left="$router.back()"
      fixed
      title="面经详细"
    />
    <header class="header">
      <h1>{{ article.stem }}</h1>
      <p>
        {{ article.createdAt }} | {{ article.views }} 浏览量 |
        {{ article.likeCount }} 点赞数
      </p>
      <p>
        <img :src="article.avatar" alt="" />
        <span>{{ article.creator }}</span>
      </p>
    </header>
    <main class="body" v-html="article.content"></main>
    <div class="opt">
      <van-icon :class="{ active: article.likeFlag }" name="like-o" />
      <van-icon :class="{ active: article.collectFlag }" name="star-o" />
    </div>
  </div>
</template>

<script>
import { getArticleDetail } from "@/api/article";

export default {
  name: "detail-page",
  data() {
    return {
      article: {},
    };
  },
  async created() {
    this.article = {};
    const { data } = await getArticleDetail(this.$route.params.id);
    this.article = data;
  },
  methods: {},
};
</script>
